//
//  HNSH_SignIntegralRecordCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/4/23.
//

#import "HNSH_SignIntegralRecordCell.h"

@interface HNSH_SignIntegralRecordCell ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;
/**  */
@property (nonatomic, strong)UILabel * nameLabel;
/**  */
@property (nonatomic, strong)UILabel * timeLabel;
/**  */
@property (nonatomic, strong)UILabel * moneyLabel;

/* lineView */
@property (nonatomic, strong) UIView *lineView;

@end

@implementation HNSH_SignIntegralRecordCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor appBGColor];
        [self configView];
    }
    return self;
}

- (void)setModel:(HNSH_IntegralBillModel *)model {
    _model = model;
    self.nameLabel.text = model.remark;
    self.timeLabel.text = model.create_time;
    if (model.income) {
        self.moneyLabel.text = [NSString stringWithFormat:@"+ %.2f", [model.amount doubleValue]];
    } else {
        self.moneyLabel.text = [NSString stringWithFormat:@"- %.2f", [model.amount doubleValue]];
    }
}

- (void)configView {
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.nameLabel];
    [self.bgView addSubview:self.timeLabel];
    [self.bgView addSubview:self.moneyLabel];
    [self.bgView addSubview:self.lineView];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.bottom.mas_equalTo(0);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(14);
        make.height.mas_equalTo(20);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLabel);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(2);
        make.height.mas_equalTo(16);
    }];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.mas_equalTo(0);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(1);
        make.bottom.mas_equalTo(0);
    }];
    self.nameLabel.text = @"打双打多撒多";
    self.timeLabel.text = @"2021-09-13  20:17:25";
    self.moneyLabel.text = @"-100.00";
}

//MARK: Getter Methods
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
    }
    return _bgView;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.textColor = [UIColor appBlackLabelColor];
    }
    return _nameLabel;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [UILabel new];
        _timeLabel.font = [UIFont systemFontOfSize:10];
        _timeLabel.textColor = [UIColor appGrayLabelColor];
    }
    return _timeLabel;
}

- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [UILabel new];
        _moneyLabel.font = [UIFont boldSystemFontOfSize:18];
        _moneyLabel.textColor = [UIColor colorWithHexString:@"#F45857"];
        _moneyLabel.textAlignment = NSTextAlignmentRight;
    }
    return _moneyLabel;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#EFEFF4"];
    }
    return _lineView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
